/*
 * @Author: YuanQuan D
 * @Date: 2025-04-04 09:20:13
 * @LastEditTime: 2025-04-08 07:25:51
 * @FilePath: \F429_arm_control_slave\User_Code\Inc\pneumatic_muscle_control.h
 */
#ifndef _PNEUMATIC_MUSCLE_CONTROL_H_
#define _PNEUMATIC_MUSCLE_CONTROL_H_


#include "main.h"
#include "cmsis_os.h"

// 通式
#define CHANNELS 7
#define ARR_COUNT 2000
#define trachea_init 832  // 0.4Mpa
#define trachea_init_bar 4.0 
#define wrist_tratrachea_initchea_max_limit 1088
#define wrist_trachea_min_limit 576
#define wrist_trachea_max_limit 1088
#define elbow_trachea_max_limit 1088
#define elbow_trachea_min_limit 576
#define trachea_zero_output 320
#define trachea_1_6_bias 13
#define trachea_range (wrist_trachea_max_limit + wrist_trachea_min_limit)
#define slide_window 100
#define pp_num 7

typedef struct{
    float kp;
    float ki;
    float kd;
    float error_N;
    float error_L;
    double output_real;
    int32_t output;
}pressure_pid;

void PPV_Cal();
void adc_init(void);
void adc_stop(void);
void ppv_init(void);
void ppv_wrist_control(void);
void ppv_elbow_control(void);
void expect_angle_change(void);
void PAM_PID_Init(void);

#endif